package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.ems.pojo.DeviceMonitorVO;
import com.econ.powercloud.ems.pojo.HisChartDataVO;
import com.econ.powercloud.ems.pojo.RunMonitorVO;
import com.econ.powercloud.ems.pojo.StrategyControlVO;
import com.econ.powercloud.ems.service.biz.EmsAdvancedStrategyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ Description:
 * @ Author：hgp
 * @ Create:2023-02-23-16:34
 */
@RestController
@Validated
@Api(tags ="大屏")
@RequestMapping(value = "/api/v2/device/monitor")
public class EmsStationMonitorController extends ApiBaseController{
    @Autowired
    private EmsAdvancedStrategyService emsAdvancedStrategyService;

    @ApiOperation(value = "获取当前SOC、今日充电量、放电量、用电量")
    @GetMapping(value = "/runMonitor")
    public MsgResult<RunMonitorVO> runMonitor(){
        return successHandler(emsAdvancedStrategyService.runMonitor());
    }

    @ApiOperation(value = "根据模块位置获取历史数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "module", value = "模块位置", dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "isAsc", value = "是否升序", dataType = "boolean"),
            @ApiImplicitParam(paramType = "query", name = "startTime", value = "开始时间",dataType = "long"),
            @ApiImplicitParam(paramType = "query", name = "endTime", value = "结束时间",dataType = "long"),
    })
    @GetMapping(value = "getHisDataByModule")
    public MsgResult<List<HisChartDataVO>> getHisDataByModule(@RequestParam("module") Integer module,
                                                              @RequestParam("isAsc") Boolean isAsc,
                                                              @RequestParam(value = "startTime") Long startTime,
                                                              @RequestParam(value = "endTime") Long endTime){
        return successHandler(emsAdvancedStrategyService.getHisDataByModule(module, isAsc, startTime, endTime));
    }

    @ApiOperation(value = "根据模块位置获取7天历史数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "module", value = "模块位置", dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "isAsc", value = "是否升序", dataType = "boolean")
    })
    @GetMapping(value = "getSevenDayHisDataByModule")
    public MsgResult<List<HisChartDataVO>> getSevenDayHisDataByModule(@RequestParam("module") Integer module,
                                                              @RequestParam("isAsc") Boolean isAsc){
        return successHandler(emsAdvancedStrategyService.getSevenDayHisDataByModule(module, isAsc));
    }
    
    @ApiOperation(value = "获取设备监控模块的实时数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "showType", value = "展示类型", dataType = "Integer")
    })
    @GetMapping(value = "getDeviceMonitor")
    public MsgResult<List<DeviceMonitorVO>> getDeviceMonitor(@RequestParam("stationId") String stationId,
                                                             @RequestParam("showType") Integer showType){
        return successHandler(emsAdvancedStrategyService.getDeviceMonitor(stationId,showType));
    }

}
